package com.lv.thumb.controller;

import com.lv.thumb.common.BaseResponse;
import com.lv.thumb.common.ResultUtils;
import com.lv.thumb.model.dto.thumb.DoThumbRequest;
import com.lv.thumb.service.ThumbService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.pulsar.shade.io.swagger.annotations.Api;
import org.apache.pulsar.shade.io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *  点赞接口
 *
 *  @author lv
 */
@RestController
@Api(tags = "点赞接口")
@RequestMapping("thumb")
public class ThumbController {  
    @Resource
    private ThumbService thumbService;

    /**
     *  点赞
     * @param doThumbRequest 点赞请求
     * @param request   请求
     * @return  点赞结果
     * @author lv
     */
    @ApiOperation( value = "点赞", notes = "点赞")
    @PostMapping("/do")
    public BaseResponse<Boolean> doThumb(@RequestBody DoThumbRequest doThumbRequest, HttpServletRequest request) {
        Boolean success = thumbService.doThumb(doThumbRequest, request);  
        return ResultUtils.success(success);
    }

    /**
     * 取消点赞
     * @param doThumbRequest 点赞请求
     * @param request   请求
     * @return  {@link Boolean }
     * @author lv
     */
    @ApiOperation( value = "取消点赞", notes = "取消点赞")
    @PostMapping("/undo")
    public BaseResponse<Boolean> undoThumb(@RequestBody DoThumbRequest doThumbRequest, HttpServletRequest request) {
        Boolean success = thumbService.undoThumb(doThumbRequest, request);
        return ResultUtils.success(success);
    }

}
